@dss-kit/ui-kit 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { createColumnHelper } from '@tanstack/react-table';
2
2
  import { TableProps } from './Table.types';
3
3
  declare const Table: {
4
- <TData>({ ref, data, columns, showBorders, enableSorting, enablePagination, enableRowSelection, enableMultiRowSelection, enableColumnPinning, columnPinning: controlledColumnPinning, onColumnPinningChange, sorting: controlledSorting, onSortingChange, columnFilters: controlledColumnFilters, onColumnFiltersChange, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, pagination: controlledPagination, onPaginationChange, rowSelection: controlledRowSelection, onRowSelectionChange, totalCount, loading, emptyLabels, loadingLabels, className, containerClassName, theadClassName, tbodyClassName, emptyStateClassName, emptyStateTitleClassName, emptyStateDescriptionClassName, paginationClassName, tableOptions, onRowClick, getRowId, headCellComponent: HeadCellComponent, bodyCellComponent: BodyCellComponent, headRowComponent: HeadRowComponent, bodyRowComponent: BodyRowComponent, onReset, paginationVariant, paginationLabels, renderPageSizeSelectorDropdownItem, renderPageSizeSelectorInputItem, }: TableProps<TData>): import("react/jsx-runtime").JSX.Element;
4
+ <TData>({ ref, data, columns, showBorders, enableSorting, enablePagination, enableRowSelection, enableMultiRowSelection, enableColumnPinning, columnPinning: controlledColumnPinning, onColumnPinningChange, sorting: controlledSorting, onSortingChange, manualSorting, columnFilters: controlledColumnFilters, onColumnFiltersChange, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, pagination: controlledPagination, onPaginationChange, rowSelection: controlledRowSelection, onRowSelectionChange, totalCount, loading, emptyLabels, loadingLabels, className, containerClassName, theadClassName, tbodyClassName, emptyStateClassName, emptyStateTitleClassName, emptyStateDescriptionClassName, paginationClassName, tableOptions, onRowClick, getRowId, headCellComponent: HeadCellComponent, bodyCellComponent: BodyCellComponent, headRowComponent: HeadRowComponent, bodyRowComponent: BodyRowComponent, onReset, paginationVariant, paginationLabels, renderPageSizeSelectorDropdownItem, renderPageSizeSelectorInputItem, }: TableProps<TData>): import("react/jsx-runtime").JSX.Element;
5
5
  displayName: string;
6
6
  HeadCellContent: import('react').ForwardRefExoticComponent<Omit<import('../Box').BoxProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
7
7
  BodyCellContent: import('react').ForwardRefExoticComponent<Omit<import('../Box').BoxProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,229 +1,231 @@
1
- import { jsx as o, jsxs as T } from "react/jsx-runtime";
2
- import { cx as r, css as M } from "@emotion/css";
3
- import { useReactTable as Re, getPaginationRowModel as xe, getSortedRowModel as Pe, getCoreRowModel as Te, flexRender as H, createColumnHelper as He } from "@tanstack/react-table";
1
+ import { jsx as o, jsxs as H } from "react/jsx-runtime";
2
+ import { cx as m, css as B } from "@emotion/css";
3
+ import { useReactTable as Pe, getPaginationRowModel as Te, getSortedRowModel as He, getCoreRowModel as Me, flexRender as M, createColumnHelper as ve } from "@tanstack/react-table";
4
4
  import { useImperativeHandle as Ne } from "react";
5
- import ve from "../../../assets/svg/table/loading.svg.js";
6
- import Me from "../../../assets/svg/table/search.svg.js";
7
- import { styles as ze } from "./styles.js";
5
+ import Be from "../../../assets/svg/table/loading.svg.js";
6
+ import ze from "../../../assets/svg/table/search.svg.js";
7
+ import { styles as Ie } from "./styles.js";
8
8
  import { useControllableState as t } from "./Table.hooks.js";
9
- import { getColumnPinningStyles as N } from "./Table.utils.js";
10
- import { TablePlaceholder as v } from "./TablePlaceholder/TablePlaceholder.js";
11
- import { TableWrapper as Be } from "./TableWrapper/TableWrapper.js";
12
- import { TableHeadRow as Ie } from "./TableHeadRow/TableHeadRow.js";
13
- import { TablePagination as Ve } from "./TablePagination/TablePagination.js";
14
- import { TableHeadCell as ke } from "./TableHeadCell/TableHeadCell.js";
15
- import { TableBodyCell as Fe } from "./TableBodyCell/TableBodyCell.js";
16
- import { TableBodyRow as We } from "./TableBodyRow/TableBodyRow.js";
17
- import { TableHeadCellContent as je } from "./TableHeadCellContent/TableHeadCellContent.js";
18
- import { TableBodyCellContent as Le } from "./TableBodyCellContent/TableBodyCellContent.js";
19
- import { TableHeadCellContentSortable as De } from "./TableHeadCellContentSortable/TableHeadCellContentSortable.js";
20
- import { theme as qe } from "../../../utils/theme/index.js";
21
- import { Box as Ae } from "../Box/Box.js";
22
- const { spacing: f, color: l } = qe, Ee = M({
9
+ import { getColumnPinningStyles as v } from "./Table.utils.js";
10
+ import { TablePlaceholder as N } from "./TablePlaceholder/TablePlaceholder.js";
11
+ import { TableWrapper as Ve } from "./TableWrapper/TableWrapper.js";
12
+ import { TableHeadRow as ke } from "./TableHeadRow/TableHeadRow.js";
13
+ import { TablePagination as Fe } from "./TablePagination/TablePagination.js";
14
+ import { TableHeadCell as je } from "./TableHeadCell/TableHeadCell.js";
15
+ import { TableBodyCell as We } from "./TableBodyCell/TableBodyCell.js";
16
+ import { TableBodyRow as Le } from "./TableBodyRow/TableBodyRow.js";
17
+ import { TableHeadCellContent as De } from "./TableHeadCellContent/TableHeadCellContent.js";
18
+ import { TableBodyCellContent as qe } from "./TableBodyCellContent/TableBodyCellContent.js";
19
+ import { TableHeadCellContentSortable as Ae } from "./TableHeadCellContentSortable/TableHeadCellContentSortable.js";
20
+ import { theme as Ee } from "../../../utils/theme/index.js";
21
+ import { Box as Ge } from "../Box/Box.js";
22
+ const { spacing: f, color: l } = Ee, Je = B({
23
23
  width: "100%",
24
24
  maxWidth: "100%",
25
25
  minWidth: "max-content",
26
26
  borderCollapse: "collapse",
27
27
  borderSpacing: 0,
28
28
  backgroundColor: l.fill.bgPrimary
29
- }), Ge = M({
29
+ }), Ke = B({
30
30
  backgroundColor: l.fill.bgSecondary,
31
31
  color: l.text.tertiary
32
- }), m = ({
32
+ }), s = ({
33
33
  ref: z,
34
- data: g,
35
- columns: B,
34
+ data: c,
35
+ columns: I,
36
36
  showBorders: d = !0,
37
- enableSorting: I = !1,
37
+ enableSorting: V = !1,
38
38
  enablePagination: b = !1,
39
- enableRowSelection: V = !1,
40
- enableMultiRowSelection: k = !1,
39
+ enableRowSelection: k = !1,
40
+ enableMultiRowSelection: F = !1,
41
41
  enableColumnPinning: p = !1,
42
- columnPinning: F,
42
+ columnPinning: j,
43
43
  onColumnPinningChange: W,
44
- sorting: j,
45
- onSortingChange: L,
46
- columnFilters: D,
47
- onColumnFiltersChange: q,
48
- columnVisibility: A,
49
- onColumnVisibilityChange: E,
50
- pagination: G,
51
- onPaginationChange: J,
52
- rowSelection: K,
53
- onRowSelectionChange: O,
54
- totalCount: s,
44
+ sorting: L,
45
+ onSortingChange: D,
46
+ manualSorting: q,
47
+ columnFilters: A,
48
+ onColumnFiltersChange: E,
49
+ columnVisibility: G,
50
+ onColumnVisibilityChange: J,
51
+ pagination: K,
52
+ onPaginationChange: O,
53
+ rowSelection: Q,
54
+ onRowSelectionChange: U,
55
+ totalCount: i,
55
56
  loading: u = !1,
56
- emptyLabels: Q = {
57
+ emptyLabels: X = {
57
58
  title: "Nothing found",
58
- description: "No results found for “result”",
59
+ description: "Try adjusting your search or filters",
59
60
  action: "Reset"
60
61
  },
61
- loadingLabels: U = {
62
+ loadingLabels: Y = {
62
63
  title: "Loading...",
63
64
  description: "Please wait or reset your promt",
64
65
  action: "Reset"
65
66
  },
66
- className: X,
67
+ className: Z,
67
68
  containerClassName: C,
68
- theadClassName: Y,
69
- tbodyClassName: Z,
69
+ theadClassName: _,
70
+ tbodyClassName: $,
70
71
  emptyStateClassName: S,
71
72
  emptyStateTitleClassName: y,
72
73
  emptyStateDescriptionClassName: w,
73
- paginationClassName: _,
74
- tableOptions: $ = {},
74
+ paginationClassName: ee,
75
+ tableOptions: oe = {},
75
76
  onRowClick: R,
76
- getRowId: ee,
77
- headCellComponent: oe = ke,
78
- bodyCellComponent: le = Fe,
79
- headRowComponent: ne = Ie,
80
- bodyRowComponent: te = We,
77
+ getRowId: le,
78
+ headCellComponent: ne = je,
79
+ bodyCellComponent: te = We,
80
+ headRowComponent: ie = ke,
81
+ bodyRowComponent: ae = Le,
81
82
  onReset: x,
82
- paginationVariant: ie,
83
- paginationLabels: ae,
84
- renderPageSizeSelectorDropdownItem: re,
85
- renderPageSizeSelectorInputItem: me
83
+ paginationVariant: re,
84
+ paginationLabels: me,
85
+ renderPageSizeSelectorDropdownItem: se,
86
+ renderPageSizeSelectorInputItem: ge
86
87
  }) => {
87
- const [se, ce] = t(
88
- j,
88
+ const [ce, de] = t(
89
89
  L,
90
- []
91
- ), [ge, de] = t(
92
90
  D,
93
- q,
94
91
  []
95
92
  ), [pe, Ce] = t(
96
93
  A,
97
94
  E,
98
- {}
99
- ), [n, h] = t(
95
+ []
96
+ ), [he, fe] = t(
100
97
  G,
101
98
  J,
99
+ {}
100
+ ), [n, h] = t(
101
+ K,
102
+ O,
102
103
  { pageIndex: 0, pageSize: 10 }
103
- ), [he, fe] = t(K, O, {}), [be, ue] = t(
104
- F,
104
+ ), [be, ue] = t(Q, U, {}), [Se, ye] = t(
105
+ j,
105
106
  W,
106
107
  { left: [], right: [] }
107
- ), i = Re({
108
- data: g,
109
- columns: B,
108
+ ), P = q ?? !!i, a = Pe({
109
+ data: c,
110
+ columns: I,
110
111
  state: {
111
- sorting: se,
112
- columnFilters: ge,
113
- columnVisibility: pe,
112
+ sorting: ce,
113
+ columnFilters: pe,
114
+ columnVisibility: he,
114
115
  pagination: n,
115
- rowSelection: he,
116
- columnPinning: be
116
+ rowSelection: be,
117
+ columnPinning: Se
117
118
  },
118
- onSortingChange: ce,
119
- onColumnFiltersChange: de,
120
- onColumnVisibilityChange: Ce,
119
+ onSortingChange: de,
120
+ onColumnFiltersChange: Ce,
121
+ onColumnVisibilityChange: fe,
121
122
  onPaginationChange: h,
122
- onRowSelectionChange: fe,
123
- onColumnPinningChange: ue,
124
- getCoreRowModel: Te(),
125
- getSortedRowModel: I ? Pe() : void 0,
126
- getPaginationRowModel: b ? xe() : void 0,
127
- enableRowSelection: V,
128
- enableMultiRowSelection: k,
123
+ onRowSelectionChange: ue,
124
+ onColumnPinningChange: ye,
125
+ getCoreRowModel: Me(),
126
+ getSortedRowModel: V && !P ? He() : void 0,
127
+ getPaginationRowModel: b ? Te() : void 0,
128
+ enableRowSelection: k,
129
+ enableMultiRowSelection: F,
129
130
  enableColumnPinning: p,
130
- getRowId: ee,
131
- manualPagination: !!s,
132
- pageCount: s ? Math.ceil(s / n.pageSize) : void 0,
133
- ...$
131
+ getRowId: le,
132
+ manualSorting: P,
133
+ manualPagination: !!i,
134
+ pageCount: i ? Math.ceil(i / n.pageSize) : void 0,
135
+ ...oe
134
136
  });
135
- Ne(z, () => i);
136
- const { rows: P } = i.getRowModel(), Se = (e, a) => {
137
- R && R(e.original, a);
138
- }, ye = (e) => /* @__PURE__ */ o(
139
- oe,
137
+ Ne(z, () => a);
138
+ const { rows: T } = a.getRowModel(), we = (e, r) => {
139
+ R && R(e.original, r);
140
+ }, Re = (e) => /* @__PURE__ */ o(
141
+ ne,
140
142
  {
141
143
  style: {
142
144
  width: e.getSize(),
143
- ...p && N(i, e.column, l.fill.bgSecondary)
145
+ ...p && v(a, e.column, l.fill.bgSecondary)
144
146
  },
145
147
  onClick: e.column.getToggleSortingHandler(),
146
- children: e.isPlaceholder ? null : H(e.column.columnDef.header, e.getContext())
148
+ children: e.isPlaceholder ? null : M(e.column.columnDef.header, e.getContext())
147
149
  },
148
150
  e.id
149
- ), we = (e, a) => /* @__PURE__ */ o(
150
- te,
151
+ ), xe = (e, r) => /* @__PURE__ */ o(
152
+ ae,
151
153
  {
152
154
  showBorders: d,
153
155
  isSelected: e.getIsSelected(),
154
- onClick: () => Se(e, a),
155
- children: e.getVisibleCells().map((c) => /* @__PURE__ */ o(
156
- le,
156
+ onClick: () => we(e, r),
157
+ children: e.getVisibleCells().map((g) => /* @__PURE__ */ o(
158
+ te,
157
159
  {
158
- style: p ? N(i, c.column, l.fill.bgPrimary) : void 0,
159
- children: H(c.column.columnDef.cell, c.getContext())
160
+ style: p ? v(a, g.column, l.fill.bgPrimary) : void 0,
161
+ children: M(g.column.columnDef.cell, g.getContext())
160
162
  },
161
- c.id
163
+ g.id
162
164
  ))
163
165
  },
164
166
  e.id
165
167
  );
166
168
  return u ? /* @__PURE__ */ o(
167
- v,
169
+ N,
168
170
  {
169
171
  icon: /* @__PURE__ */ o(
170
- ve,
172
+ Be,
171
173
  {
172
174
  width: 32,
173
175
  height: 32,
174
176
  style: { color: l.icon.tertiary, marginBottom: f.sm }
175
177
  }
176
178
  ),
177
- labels: U,
179
+ labels: Y,
178
180
  onReset: x,
179
- className: r(C, S),
181
+ className: m(C, S),
180
182
  titleClassName: y,
181
183
  descriptionClassName: w
182
184
  }
183
- ) : P.length ? /* @__PURE__ */ T(Ae, { w: "full", gap: f.xl, className: r(C), children: [
184
- /* @__PURE__ */ o(Be, { data: g, showBorders: d, children: /* @__PURE__ */ T("table", { className: r(Ee, ze.table, X), children: [
185
- /* @__PURE__ */ o("thead", { className: r(Ge, Y), children: i.getHeaderGroups().map((e) => /* @__PURE__ */ o(ne, { showBorders: d, children: e.headers.map(ye) }, e.id)) }),
186
- /* @__PURE__ */ o("tbody", { className: Z, children: P.map((e, a) => we(e, a)) })
185
+ ) : T.length ? /* @__PURE__ */ H(Ge, { w: "full", gap: f.xl, className: m(C), children: [
186
+ /* @__PURE__ */ o(Ve, { data: c, showBorders: d, children: /* @__PURE__ */ H("table", { className: m(Je, Ie.table, Z), children: [
187
+ /* @__PURE__ */ o("thead", { className: m(Ke, _), children: a.getHeaderGroups().map((e) => /* @__PURE__ */ o(ie, { showBorders: d, children: e.headers.map(Re) }, e.id)) }),
188
+ /* @__PURE__ */ o("tbody", { className: $, children: T.map((e, r) => xe(e, r)) })
187
189
  ] }) }),
188
190
  b && !u && /* @__PURE__ */ o(
189
- Ve,
191
+ Fe,
190
192
  {
191
193
  pageIndex: n.pageIndex,
192
194
  pageSize: n.pageSize,
193
- totalCount: s || g.length,
194
- variant: ie,
195
- labels: ae,
196
- renderPageSizeSelectorDropdownItem: re,
197
- renderPageSizeSelectorInputItem: me,
195
+ totalCount: i || c.length,
196
+ variant: re,
197
+ labels: me,
198
+ renderPageSizeSelectorDropdownItem: se,
199
+ renderPageSizeSelectorInputItem: ge,
198
200
  onPageChange: (e) => h({ ...n, pageIndex: e }),
199
201
  onPageSizeChange: (e) => h({ ...n, pageSize: e, pageIndex: 0 }),
200
- className: _
202
+ className: ee
201
203
  }
202
204
  )
203
205
  ] }) : /* @__PURE__ */ o(
204
- v,
206
+ N,
205
207
  {
206
208
  icon: /* @__PURE__ */ o(
207
- Me,
209
+ ze,
208
210
  {
209
211
  width: 24,
210
212
  height: 24,
211
213
  style: { color: l.icon.tertiary, marginBottom: f.sm }
212
214
  }
213
215
  ),
214
- labels: Q,
216
+ labels: X,
215
217
  onReset: x,
216
- className: r(C, S),
218
+ className: m(C, S),
217
219
  titleClassName: y,
218
220
  descriptionClassName: w
219
221
  }
220
222
  );
221
223
  };
222
- m.displayName = "Table";
223
- m.HeadCellContent = je;
224
- m.BodyCellContent = Le;
225
- m.HeadCellContentSortable = De;
226
- m.createColumnHelper = He;
224
+ s.displayName = "Table";
225
+ s.HeadCellContent = De;
226
+ s.BodyCellContent = qe;
227
+ s.HeadCellContentSortable = Ae;
228
+ s.createColumnHelper = ve;
227
229
  export {
228
- m as Table
230
+ s as Table
229
231
  };
@@ -32,6 +32,17 @@ export interface TableProps<TData> {
32
32
  sorting?: SortingState;
33
33
  /** Callback при изменении сортировки */
34
34
  onSortingChange?: (sorting: SortingState) => void;
35
+ /**
36
+ * Серверная (manual) сортировка. Когда `true`, таблица не сортирует данные
37
+ * на клиенте — она лишь сообщает о смене состояния через `onSortingChange`,
38
+ * а отсортированные данные должен вернуть бэкенд. Используйте вместе с
39
+ * контролируемым `sorting`, чтобы отображать активную колонку и направление.
40
+ *
41
+ * По умолчанию включается автоматически, когда задан `totalCount`
42
+ * (признак серверной пагинации).
43
+ * @default Boolean(totalCount)
44
+ */
45
+ manualSorting?: boolean;
35
46
  /** Состояние фильтров (контролируемое) */
36
47
  columnFilters?: ColumnFiltersState;
37
48
  /** Callback при изменении фильтров */
@@ -72,7 +83,7 @@ export interface TableProps<TData> {
72
83
  /** @default false */
73
84
  loading?: boolean;
74
85
  /** Сообщение при отсутствии данных */
75
- /** @default { title: "Nothing found", description: "No results found for “result”", action: "Reset" } */
86
+ /** @default { title: "Nothing found", description: "Try adjusting your search or filters", action: "Reset" } */
76
87
  emptyLabels?: {
77
88
  title: string;
78
89
  description: string;
@@ -1,10 +1,10 @@
1
- import { jsxs as d, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
2
  import { Button as l } from "../../../controls/Button/Button.js";
3
3
  import { Box as s } from "../../Box/Box.js";
4
4
  import { theme as p } from "../../../../utils/theme/index.js";
5
- import { Text as e } from "../../Text/Text.js";
6
- const { spacing: o, cornerRadius: h } = p, f = ({
7
- icon: r,
5
+ import { Text as r } from "../../Text/Text.js";
6
+ const { spacing: e, cornerRadius: h } = p, f = ({
7
+ icon: i,
8
8
  labels: t,
9
9
  onReset: n,
10
10
  className: c,
@@ -15,34 +15,36 @@ const { spacing: o, cornerRadius: h } = p, f = ({
15
15
  {
16
16
  w: "full",
17
17
  borderRadius: h.md,
18
- py: o["5xl"],
19
- px: o["10xl"],
18
+ py: e["5xl"],
19
+ px: e["10xl"],
20
20
  alignItems: "center",
21
21
  className: c,
22
22
  children: [
23
- r,
24
- /* @__PURE__ */ i(
25
- e,
23
+ i,
24
+ /* @__PURE__ */ o(
25
+ r,
26
26
  {
27
- mb: o.xs,
27
+ mb: e.xs,
28
28
  variant: "title-3",
29
29
  fontWeight: "semibold",
30
30
  className: m,
31
+ center: !0,
31
32
  children: t.title
32
33
  }
33
34
  ),
34
- /* @__PURE__ */ i(
35
- e,
35
+ /* @__PURE__ */ o(
36
+ r,
36
37
  {
37
- mb: o.md,
38
+ mb: e.md,
38
39
  colorName: "tertiary",
39
40
  variant: "body-1",
40
41
  fontWeight: "medium",
41
42
  className: a,
43
+ center: !0,
42
44
  children: t.description
43
45
  }
44
46
  ),
45
- typeof t.action == "string" ? /* @__PURE__ */ i(
47
+ typeof t.action == "string" ? /* @__PURE__ */ o(
46
48
  l,
47
49
  {
48
50
  width: "auto",